<?php

//sleep(4);
include 'lib.php';
include 'getCourses.php';
include 'config.php';

$course = $_GET['course'];
$year = $_GET['year'];

$c = $courses[strtolower($course)];

if($course == null || $year < 2001){
	echo "Wrong data.";
	exit();
}

$locale = "de";
if(isset($_GET['locale'])){
	$locale = substr($_GET['locale'], 0, 2);
}

$filename = randstring();

// Create files
$file[] = $config['root'].'cookies/'.$filename;
$file[] = $config['root'].'results/'.$filename;

foreach($file as $f){
	$fh = fopen($f, 'w');
	fclose($fh);
}

getStudents($file, $c, $year);
//parseStudentsOutsideUAS($file, $course, $year);
parseStudents($file, $c, $year);
//echo file_get_contents($file[1]);

/*
parseExams($file);

// Clenup
foreach($file as $f){
	unlink($f);
}
 * */

?>
